from System import *
from System.Net import *
from System.Windows.Media import *
from System.Windows.Media.Imaging import *

def log(msg):
  document.msg.innerHTML = str(msg)

def lightbox(image_src):
  HtmlPage.Plugin.SetStyleAttribute("left", "0px")
  me.desc.Text = image_src
  me.pic.Source = BitmapImage(Uri(image_src))
  me.fade_in.Begin()

def close_lightbox(s=None,e=None):
  HtmlPage.Plugin.SetStyleAttribute("left", "-5000px")

def setup_canvas():
  HtmlPage.Plugin.SetStyleAttribute("position","absolute")
  HtmlPage.Plugin.SetStyleAttribute("top","0px")
  close_lightbox()
  HtmlPage.Plugin.Width = "100%"
  HtmlPage.Plugin.Height = "100%"
  me.LayoutRoot.MouseLeftButtonDown += close_lightbox

setup_canvas()
document.thumb.AttachEvent("onclick", EventHandler[HtmlEventArgs](lambda s,e: lightbox(s.src)))
document.thumb2.AttachEvent("onclick", EventHandler[HtmlEventArgs](lambda s,e: lightbox(s.src)))